<template>
	<view class="page">
		<!-- 头像 -->
		<view class="flex flex-row flex-center">
			<u-cell-group>
				<u-cell title="昵称" >
					<view slot="title" class="flex "  @click="Login">
						<u-avatar :src="userInfo.avatarUrl" size="80"></u-avatar>
						<view class="margin-left"></view>
						<u--text size="23px"  color="black" :text="userInfo.username" ></u--text>
					</view>
				</u-cell>
			</u-cell-group>
		</view>

		<view class="flex flex-column flex-center ">
			<view class="background  border-radius  box-shadow padding orderItem"  @click="gotoOrder()">
				<u--text color="black" text="我的订单"></u--text>
				<view class="flex flex-row justify-between margin-top ">
					<u-icon label="待支付" labelPos="bottom" name="setting"></u-icon>
					<u-icon label="已支付" labelPos="bottom" name="setting"></u-icon>
					<u-icon label="全部订单" labelPos="bottom" name="setting"></u-icon>
				</view>
				<u-divider ></u-divider>
				<view v-for="(items,indexs) in list3" :key="indexs">
					<view  class="flex flex-row justify-between background item"
						@click="navigator(items.url)">
						<!-- 图标  文字  加载更多  -->
						<u-icon :name="items.icon" labelSize="35rpx" size="25px" :label="items.name"></u-icon>
						<u-icon name="arrow-right"></u-icon>
					</view>
					<u-divider></u-divider>
				</view>
				<u-button type="info" text="退出登录" @click="layout"></u-button>

			</view>
		</view>


	</view>
</template>

<script>
	import store from '@/pages/store/index.js'
	export default {
		data() {
			return {
				isLogin: false,
				src: '/static/images/index/slider1.jpg',
				userInfo: {},
				list3: [{
						id: 1,
						name: '任务中心',

						icon: 'heart'
					},
					{
						id: 1,
						name: '个人信息',
						url: '/pages/my/edit/edit',
						icon: 'account'
					},
					{
						id: 1,
						name: '账号与安全',
						// url: '',
						icon: 'setting'
					}
				],
				isLogin: false,
				userId: null,

			}
		},
		onLoad() {
			this.userId = uni.getStorageSync('userId');
			this.getUserById();
		},
		methods: {
			Login() {
				uni.navigateTo({
					url: "/pages/my/login/login"
				})
			},
			getUserById() {
				uni.request({
					url: 'http://localhost:8083/user/' + this.userId,
					success: (res) => {
						this.userInfo = res.data;
						this.editInfo = {
							...this.userInfo
						};
					},
					fail: (err) => {
						console.log(err);
					}
				});
			},

			layout() {
				uni.removeStorageSync('userInfo')
				this.isLogin = "true"
				uni.reLaunch({
					url: "/pages/index/index"
				})
				uni.showToast({
					title: "退出成功",
					icon: 'success'
				})
				this.userId = null;
			},
			navigator(url) {
				console.log(url)
				uni.navigateTo({
					url: '/pages/my/edit/edit'
				})
			},
			gotoOrder(){
				uni.navigateTo({
					url:'/pages/my/order/order'
				})
			}
			// goTo() {
				
			// 	uni.navigateTo({
			// 		url:'/pages/my/order/order'
			// 	})
			// },



		}
	}
</script>
<style lang="scss">
	.orderItem{
		width: 85%;
	}
	
	.item{
		height: 38px;
	}
	
	
</style>